/**
 * Methods used by main algorithms for SNF.
 */

#include "utils.h"

#include <cstdlib>
#include <cstdio>
#include <ctime>

/*
 * Transforms an upper triangular band matrix into a diagonal matrix.
 */
int utils::bandToDiag(int *A, unsigned int n);

/*
 * Transforms a diagonal matrix into SNF.
 */
int utils::diagToSmith(int *A, unsigned int n);

/*
 * Unimodular operation to replace the first element with the gcd of itself and another in the row.
 */
int utils::gcdRow(int *A, int row, int colI, int colJ, unsigned int n)
{
  return 0;
}

/*
 * Unimodular operation to replace the first element with the gcd of itself and another in the col.
 */
int utils::gcdCol(int *A, int col, int rowI, int rowJ, unsigned int n);

/*
 * Prints the matrix.
 */
int utils::printMatrix(int *A, unsigned int n)
{
  for (unsigned int i = 0; i < n; i++)
    {
      for (unsigned int j = 0; j < n; j++)
	{
	  printf("%i  ", A[RIDX(i, j, n)]);
	}
      printf("\n");
    }
    
  return 0;
}

/*
 * Randomizes the elements of a matrix.
 */
int utils::randomizeMatrix(int *A, unsigned int n)
{
  unsigned int size = n*n;
  // Randomize elements
  srand(time(NULL));
  for (unsigned int i = 0; i < size; i++)
  {
    A[i] = rand() % 10;
  }

  return 0;
}


